package com.ruoyi.neusoft.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.neusoft.domain.AiIdentifyCollectionT;
import com.ruoyi.neusoft.service.IAiIdentifyCollectionTService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * AI智能识别数据集Controller
 * 
 * @author ruoyi
 * @date 2024-04-17
 */
@Controller
@RequestMapping("/AI/collectionService")
public class AiIdentifyCollectionTController extends BaseController
{
    private String prefix = "AI/collectionService";

    @Autowired
    private IAiIdentifyCollectionTService aiIdentifyCollectionTService;

    @RequiresPermissions("AI:collectionService:view")
    @GetMapping()
    public String collectionService()
    {
        return prefix + "/collectionService";
    }

    /**
     * 查询AI智能识别数据集列表
     */
    @RequiresPermissions("AI:collectionService:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AiIdentifyCollectionT aiIdentifyCollectionT)
    {
        startPage();
        List<AiIdentifyCollectionT> list = aiIdentifyCollectionTService.selectAiIdentifyCollectionTList(aiIdentifyCollectionT);
        return getDataTable(list);
    }

    /**
     * 导出AI智能识别数据集列表
     */
    @RequiresPermissions("AI:collectionService:export")
    @Log(title = "AI智能识别数据集", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AiIdentifyCollectionT aiIdentifyCollectionT)
    {
        List<AiIdentifyCollectionT> list = aiIdentifyCollectionTService.selectAiIdentifyCollectionTList(aiIdentifyCollectionT);
        ExcelUtil<AiIdentifyCollectionT> util = new ExcelUtil<AiIdentifyCollectionT>(AiIdentifyCollectionT.class);
        return util.exportExcel(list, "AI智能识别数据集数据");
    }

    /**
     * 新增AI智能识别数据集
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存AI智能识别数据集
     */
    @RequiresPermissions("AI:collectionService:add")
    @Log(title = "AI智能识别数据集", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AiIdentifyCollectionT aiIdentifyCollectionT)
    {
        return toAjax(aiIdentifyCollectionTService.insertAiIdentifyCollectionT(aiIdentifyCollectionT));
    }

    /**
     * 修改AI智能识别数据集
     */
    @RequiresPermissions("AI:collectionService:edit")
    @GetMapping("/edit/{collectionId}")
    public String edit(@PathVariable("collectionId") Long collectionId, ModelMap mmap)
    {
        AiIdentifyCollectionT aiIdentifyCollectionT = aiIdentifyCollectionTService.selectAiIdentifyCollectionTByCollectionId(collectionId);
        mmap.put("aiIdentifyCollectionT", aiIdentifyCollectionT);
        return prefix + "/edit";
    }

    /**
     * 修改保存AI智能识别数据集
     */
    @RequiresPermissions("AI:collectionService:edit")
    @Log(title = "AI智能识别数据集", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AiIdentifyCollectionT aiIdentifyCollectionT)
    {
        return toAjax(aiIdentifyCollectionTService.updateAiIdentifyCollectionT(aiIdentifyCollectionT));
    }

    /**
     * 删除AI智能识别数据集
     */
    @RequiresPermissions("AI:collectionService:remove")
    @Log(title = "AI智能识别数据集", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(aiIdentifyCollectionTService.deleteAiIdentifyCollectionTByCollectionIds(ids));
    }
}
